<template>
  <div class="list">
    <!-- 渲染多个商品(列表) -->
    <div class="good" v-for="(item,index) in tabs[currentIndex].list" :key="index">
        <div class="imgbox">
            <img :src="item.pic" alt="">
        </div>
        <div class="text">
            <div class="name">{{item.name}}</div>
            <div class="price">￥{{item.price}}</div>
        </div>
    </div>
  </div>
</template>

<script>
import eventbus from '../utils/tools'//导入实例化的vue
export default {
    data() {
        //通过props接收从父组件传来的值,该值是只读的(不能修改).
        return {
        currentIndex:0
    }
    },
    props: ['tabs'],
    mounted() {//挂载期(完成)
        eventbus.$on('deliverIndex', (index) => {//$on绑定事件
            this.currentIndex = index;//保存接收到的值
        })
}
}
</script>

<style lang="scss" scoped>
.list {
    flex: 1;
}

.list .good {
    display: flex;
    margin: 10px 0;
}

.list .good .imgbox {
    width: 80px;
    margin-right: 10px;
}

.list .good .imgbox img {
    width: 100%;
}
</style>